<?php
// +----------------------------------------------------------------------
// | quanli team
// +----------------------------------------------------------------------
// | Copyright (c) 2013-2020 http://www.fistforward.com/ All rights reserved.
// +----------------------------------------------------------------------
// | create by allen.qiang
// +----------------------------------------------------------------------


/**
 * 客户投诉
 * @package  htdocs
 * @subpackage  quanliadmin
 * @create by allen.qiang
 */
define('COMPLAINTCATEGROY' , 13);  //投诉类型分类ID

class pa_complaint {

    public function execute() {
        global $G_PGLOB ;
        if (isset($_REQUEST['operFlg'])) {

            switch($_REQUEST['operFlg']) {

                case 1: //会员投诉信息列表
                    $this->complaintList();
                    break;

                case 2: //添加会员投诉信息
                    $this->complaintAdd();
                    break;

                case 3: //编辑会员投诉信息
                    $this->complaintEdit();
                    break;

                case 4: //投诉详情
                    $this->complaintDetail();
                    break;

                default:
                    $G_PGLOB->smarty->assign('msg', '参数错误，请审核后再操作');
                    $G_PGLOB->smarty->display('comm/error.tpl');

            }
        }
    }

    /**
     * 信息列表
     *
     */
    private function complaintList() {

        global $G_PGLOB;

        //实例化字典表操作公共类
        $itemHandler = new itemHandler( $G_PGLOB->DBCA );

        //查询投诉类型信息
        $params['item'] = COMPLAINTCATEGROY;
        $itemResult = $itemHandler->searchItemList( $params );

        $G_PGLOB->smarty->assign( 'complaintArr' , $itemResult );
        $G_PGLOB->smarty->display('customer/complaint_list.tpl');

    }

    /**
     * 添加会员投诉信息
     */
    private function complaintAdd () {

        global $G_PGLOB;

        //实例化字典表操作公共类
        $itemHandler = new itemHandler( $G_PGLOB->DBCA );

        //查询投诉类型信息
        $params['item'] = COMPLAINTCATEGROY;
        $itemResult = $itemHandler->searchItemList( $params );

        $G_PGLOB->smarty->assign( 'complaintArr' , $itemResult );
        $G_PGLOB->smarty->assign('operFlg', 2);
        $G_PGLOB->smarty->display('customer/complaint_add.tpl');

    }

    /**
     * 编辑会员投诉信息
     */
    public function complaintEdit() {

        global $G_PGLOB;

        if (!isset($_REQUEST['id']) || !is_numeric($_REQUEST['id'])) {
            $G_PGLOB->smarty->assign('msg', '参数错误');
            $G_PGLOB->smarty->display('comm/error.tpl');
            die() ;
        }

        //查询客户投诉信息
        $complaint_obj = new entity('cust_complaint');
        $complaint_obj->complaintID = $_REQUEST['id'];

        if( !$G_PGLOB->DBCA->fetch($complaint_obj) ){
            $G_PGLOB->smarty->assign('msg', '没有找到信息');
            $G_PGLOB->smarty->display('comm/error.tpl');
            die() ;
        }

        if( empty( $complaint_obj->bill_no ) )
            $complaint_obj->bill_no = '';

        //实例化字典表操作公共类
        $itemHandler = new itemHandler( $G_PGLOB->DBCA );

        //查询投诉类型信息
        $params['item'] = COMPLAINTCATEGROY;
        $itemResult = $itemHandler->searchItemList( $params );

        $G_PGLOB->smarty->assign( 'complaintArr' , $itemResult );
        $G_PGLOB->smarty->assign('complaintInfo' , $complaint_obj);
        $G_PGLOB->smarty->assign('operFlg', 3);
        $G_PGLOB->smarty->display('customer/complaint_add.tpl');

    }

    /**
     * 查看投诉详情
     */
    function complaintDetail(){

        global $G_PGLOB;

        if (!isset($_REQUEST['id']) || !is_numeric($_REQUEST['id'])) {
            $G_PGLOB->smarty->assign('msg', '参数错误');
            $G_PGLOB->smarty->display('comm/error.tpl');
            die() ;
        }

        //查询客户投诉信息
        $complaint_obj = new entity('cust_complaint');
        $complaint_obj->complaintID = $_REQUEST['id'];

        if( !$G_PGLOB->DBCA->fetch($complaint_obj) ){
            $G_PGLOB->smarty->assign('msg', '没有找到信息');
            $G_PGLOB->smarty->display('comm/error.tpl');
            die() ;
        }

        if( empty( $complaint_obj->bill_no ) )
            $complaint_obj->bill_no = '';

        //实例化字典表操作公共类
        $itemHandler = new itemHandler( $G_PGLOB->DBCA );

        //查询投诉类型信息
        $params['item'] = COMPLAINTCATEGROY;
        $itemResult = $itemHandler->searchItemList( $params );

        $G_PGLOB->smarty->assign( 'complaintArr' , $itemResult );
        $G_PGLOB->smarty->assign('complaintInfo' , $complaint_obj);
        $G_PGLOB->smarty->display('customer/complaint_detail.tpl');

    }

}